<%@ page import="com.xszx.entity.TUser" %><%--
  Created by IntelliJ IDEA.
  User: 32312
  Date: 2024/1/9
  Time: 10:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"  isELIgnored="false"%>
<%
    TUser user = (TUser)request.getSession().getAttribute("user");
    String dname = (String)request.getSession().getAttribute("deptName");
    if(user.getDid() != 101){
        response.sendRedirect("/jsp/personCenterNormal.jsp");
    }
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="/resource/materialize/css/materialize.min.css" media="screen,projection" />
    <!-- Bootstrap Styles-->
    <link href="/resource/css/bootstrap.css" rel="stylesheet" />
    <!-- FontAwesome Styles-->
    <link href="/resource/css/font-awesome.css" rel="stylesheet" />
    <!-- Morris Chart Styles-->
    <link href="/resource/js/morris/morris-0.4.3.min.css" rel="stylesheet" />
    <!-- Custom Styles-->
    <link href="/resource/css/custom-styles.css" rel="stylesheet" />
    <!-- Google Fonts-->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="/resource/js/Lightweight-Chart/cssCharts.css">
    <script src="/resource/js/jquery-1.7.1.js"></script>
</head>
<body>
<div id="wrapper">
    <nav class="navbar navbar-default top-navbar" role="navigation">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand waves-effect waves-dark" href="/jsp/index.jsp"><i class="large material-icons">insert_chart</i> <strong>TRACK</strong></a>

            <div id="sideNav" href=""><i class="material-icons dp48">toc</i></div>
        </div>

        <ul class="nav navbar-top-links navbar-right">
            <li><a class="dropdown-button waves-effect waves-dark" href="#!" data-activates="dropdown1"><i class="fa fa-user fa-fw"></i> <b>${user.username}</b> </a></li>
        </ul>
    </nav>
    <!-- Dropdown Structure -->
    <ul id="dropdown1" class="dropdown-content">
        <li><a href="/jsp/form.jsp"><i class="fa fa-user fa-fw"></i> 个人中心</a>
        </li>
        <li><a href="/jsp/personCenter.jsp"><i class="fa fa-bell fa-fw"></i> 个人任务</a>
        </li>
        <li><a href="/jsp/test.jsp" target="_top"><i class="fa fa-sign-out fa-fw"></i> 注销</a>
        </li>
    </ul>
    <ul id="dropdown2" class="dropdown-content w250">
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-comment fa-fw"></i> New Comment
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-twitter fa-fw"></i> 3 New Followers
                    <span class="pull-right text-muted small">12 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-envelope fa-fw"></i> Message Sent
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-tasks fa-fw"></i> New Task
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a href="#">
                <div>
                    <i class="fa fa-upload fa-fw"></i> Server Rebooted
                    <span class="pull-right text-muted small">4 min</span>
                </div>
            </a>
        </li>
        <li class="divider"></li>
        <li>
            <a class="text-center" href="#">
                <strong>See All Alerts</strong>
                <i class="fa fa-angle-right"></i>
            </a>
        </li>
    </ul>
    <!--/. NAV TOP  -->
    <!--/. NAV TOP  -->




    <nav class="navbar-default navbar-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav" id="main-menu">

                <li>
                    <a class="active-menu waves-effect waves-dark" href="/jsp/index.jsp"><i class="fa fa-dashboard"></i> 统计</a>
                </li>

                <li>
                    <a href="#" class="waves-effect waves-dark"><i class="fa fa-sitemap"></i>固定资产管理<span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li>
                            <a href="#">资产管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>
                                    <a href="/jsp/assetTable.jsp">总资产管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetFixTable.jsp">维修资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetForbiddenTable.jsp">禁用资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetFreeTable.jsp">空闲资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetScrapTable.jsp">报废资产</a>
                                </li>
                                <li>
                                    <a href="/jsp/assetUsingTable.jsp">使用中资产</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <a href="/jsp/recordTable.jsp">合同管理</a>
                        </li>
                        <li>
                            <a href="#">系统管理<span class="fa arrow"></span></a>
                            <ul class="nav nav-third-level">
                                <li>
                                    <a href="/jsp/deptTable.jsp">部门管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/userTable.jsp">用户管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/roleTable.jsp">角色管理</a>
                                </li>
                                <li>
                                    <a href="/jsp/menuTable.jsp">菜单管理</a>
                                </li>
                            </ul>

                        </li>
                    </ul>
                </li>
                <li>
                    <a href="/jsp/empty.jsp" class="waves-effect waves-dark"><i class="fa fa-fw fa-file"></i> 日志</a>
                </li>
            </ul>

        </div>

    </nav>
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div class="header">
            <h1 class="page-header">
                个人任务
            </h1>
            <ol class="breadcrumb">
                <li><a href="#">Home</a></li>
                <li><a href="#">个人任务 </a></li>
                <li class="active">Data</li>
            </ol>

        </div>
        <div id="page-inner">

            <div class="row">
                <div class="col-md-12">
                    <!--    Hover Rows  -->
                    <div class="card">
                        <div class="card-content">
                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead>
                                    <tr>
                                        <th>申请记录ID</th>
                                        <th>资产ID</th>
                                        <th>资产名称</th>
                                        <th>部门名称</th>
                                        <th>申请状态</th>
                                        <th>申请类型</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody name="recordTable">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                    <!-- End  Hover Rows  -->
                </div>
            </div>

            <!-- /. PAGE INNER  -->
        </div>
        <!-- /. PAGE WRAPPER  -->

        <div class="modal fade details" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="sign-content">

                        <div class="modal-header">
                            <h2>查看详情</h2>
                        </div><!--/.modal-header -->

                        <div class="modal-body">
                            <div class="signin-form">
                                <div class=" ">
                                    <div class=" ">
                                        <div class="signin-footer">
                                            <div class="form-group">
                                                <label for="rid">记录ID</label>
                                                <input type="text" name="rid" class="form-control" id="rid" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="aid">资产ID</label>
                                                <input type="text" name="aid" class="form-control" id="aid" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="aname">资产名称</label>
                                                <input type="text" name="aname" class="form-control" id="aname" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="dname">部门名称</label>
                                                <input type="text" name="dname" class="form-control" id="dname" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="username">用户名称</label>
                                                <input type="text" name="username" class="form-control" id="username" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="bdate">申请日期</label>
                                                <input type="text" name="bdate" class="form-control" id="bdate" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="rstatus">申请状态</label>
                                                <input type="text" name="rstatus" class="form-control" id="rstatus" readonly>
                                            </div><!--/.form-group -->
                                            <div class="form-group">
                                                <label for="rtype">申请类型</label>
                                                <input type="text" name="rtype" class="form-control" id="rtype" readonly>
                                            </div><!--/.form-group -->
                                            <a href="/jsp/personCenter.jsp">
                                                <button type="button" class="btn signin_btn" data-toggle="modal" data-target=".signin_modal">
                                                    退出
                                                </button>
                                            </a>
                                        </div>
                                    </div><!--/.col -->
                                </div><!--/.row -->

                            </div><!--/.signin-form -->

                        </div><!--/.modal-body -->

                    </div><!--/.sign-content -->
                </div><!--/.modal-content -->
            </div><!--/.modal-dialog -->
        </div><!--/.modal -->

    </div>




    <script>

        $(function(){
            $.ajax({
                url:"/selectRecordDTO",
                //请求方式
                type:"POST",
                //数据形式
                dataType:"json",
                //请求成功后调用的回调函数
                success:function (data) {
                    console.log(data);
                    for (var i = 0;i<data.length;i++){
                        $("[name=recordTable]").append(
                            "<tr class=\"gradeU\">\n"+
                            "   <td>"+ data[i].rid+ "</td>\n"+
                            "   <td>"+ data[i].aid+ "</td>\n"+
                            "    <td>"+ data[i].aname+ "</td>\n"+
                            "    <td>"+ data[i].dname+ "</td>\n"+
                            "    <td>"+ data[i].rstatus+ "</td>\n"+
                            "    <td>"+ data[i].rtype+ "</td>\n"+
                            "   <td>\n"+
                            "     <button class=btn signin_btn data-toggle=modal data-target=.details onclick=deti("+data[i].rid+")>查看详情</button>\n"+
                            "     <button class=btn signin_btn data-toggle=modal  onclick=pass("+data[i].rid+")>通过</button>\n"+
                            "     <button class=btn signin_btn data-toggle=modal  onclick=reject("+data[i].rid+")>驳回</button>\n"+
                            "     </td>\n"+
                            "     </tr>"
                        );
                    }
                }
            })
        })

        function deti(rid){
            $.ajax({
                url:"/getRecordDTOByRid",
                data:{
                    rid:rid
                },
                type:"post",
                dataType:"json",
                success:function (data) {
                    console.log(data);
                    $("#rid").val(data.rid);
                    $("#aid").val(data.aid);
                    $("#aname").val(data.aname);
                    $("#dname").val(data.dname);
                    $("#username").val(data.username);
                    $("#bdate").val(data.borrowdate1);
                    $("#rstatus").val(data.rstatus);
                    $("#rtype").val(data.rtype);
                }
            })
        }
        //通过请求
        function pass(rid){
            alert(rid);
            $.ajax({
                url:"/obtainApprovalResult",
                data:{
                    rid:rid,
                    id:1
                },
                type:"post",
                dataType:"json",
                success:function (data){
                    console.log("驳回后传输的状态id:"+data);
                    if(data <= 0){
                        alert("审批失败！")
                    }else{
                        alert("审批成功");
                        location.href="/jsp/personCenter.jsp";
                    }
                }
            })
        }


        //驳回请求
        function reject(rid){
            alert(rid);
            $.ajax({
                url:"/obtainApprovalResult",
                data:{
                    rid:rid,
                    id:2
                },
                type:"post",
                dataType:"json",
                success:function (data){
                    console.log("驳回后传输的状态id:"+rid);
                    if(data <= 0){
                        alert("审批失败！")
                    }else{
                        alert("审批成功");
                        location.href="/jsp/personCenter.jsp";
                    }
                }
            })
        }

    </script>

    <!-- /. WRAPPER  -->
    <!-- JS Scripts-->
    <!-- jQuery Js -->
    <script src="/resource/js/jquery-1.10.2.js"></script>

    <!-- Bootstrap Js -->
    <script src="/resource/js/bootstrap.min.js"></script>

    <script src="/resource/materialize/js/materialize.min.js"></script>

    <!-- Metis Menu Js -->
    <script src="/resource/js/jquery.metisMenu.js"></script>
    <!-- Morris Chart Js -->
    <script src="/resource/js/morris/raphael-2.1.0.min.js"></script>
    <script src="/resource/js/morris/morris.js"></script>


    <script src="/resource/js/easypiechart.js"></script>
    <script src="/resource/js/easypiechart-data.js"></script>

    <script src="/resource/js/Lightweight-Chart/jquery.chart.js"></script>

    <!-- Custom Js -->
    <script src="/resource/js/custom-scripts.js"></script>

</div>

</body>

</html>

